function light(){
    setTimeout(function(){
        console.log('黄灯')
    },1000)
    setTimeout(function(){
        console.log('绿灯')
    },2000)
    setTimeout(function(){
        console.log('红灯')
    },3000)
}

light()

function delay(fn, time) {
	return new Promise((resolve) => {
		setTimeout(() => {
			resolve(fn()); // A
		}, time);
	});
}

async function light() {
	await delay(() => console.log("red"), 3000);
	await delay(() => console.log("green"), 2000);
	await delay(() => console.log("yellow"), 1000);
	await light();
}

light();
